package java0416;

//public class Test {
//    public static void main(String[] args) {
////// 定义一个空的字符串缓冲区，含有16个字符的容量
////        StringBuffer str1 = new StringBuffer();
////
////// 定义一个含有10个字符容量的字符串缓冲区
////        StringBuffer str2 = new StringBuffer(10);
////
////// 定义一个含有(16+4)的字符串缓冲区，"青春无悔"为4个字符
////        StringBuffer str3 = new StringBuffer("青春无悔");
////        /*
////         *输出字符串的容量大小
////         *capacity()方法返回字符串的容量大小
////         */
////        System.out.println(str1.capacity());    // 输出 16
////        System.out.println(str2.capacity());    // 输出 10
////        System.out.println(str3.capacity());    // 输出 20
////        System.out.println(str3);
////        StringBuffer buffer = new StringBuffer("hello");
////        StringBuffer buffer1 = new StringBuffer("hello");
////        System.out.println(buffer == buffer1);
////        System.out.println(buffer.equals(buffer1));
////        System.out.println(buffer.toString().equals(buffer1.toString()));
//////        System.out.println(buffer.append(2));
//    }
//}

//class A {
//    public A() {
//        System.out.println("A A");
//    }
//    static {
//        System.out.println("A");
//    }
//}
//
//public class Test extends A {
//    public Test() {
//        System.out.println("Test Test");
//    }
//    static {
//        System.out.println("Test");
//    }
//    public static void main(String[] args) {
//        new Test();
//    }
//}

import java.math.BigDecimal;
import java.util.*;

public class Test {
//    public static void main(String[] args) {
//        boolean b = true ? false : true == true ? false : true;
//        System.out.println(b);
//    }

    public static List<Integer> divideRedPackage(Integer totalAmount, Integer totalPeopleNum) {

        List<Integer> amountList = new ArrayList<Integer>();
        Integer restAmount = totalAmount;
        Integer restPeopleNum = totalPeopleNum;

        Random random = new Random();

        for (int i = 0; i < totalPeopleNum - 1; i++) {
            //随机范围：[1，剩余人均金额的两倍)，左闭右开
            int amount = random.nextInt(restAmount / restPeopleNum * 2 - 1) + 1;
            restAmount -= amount;
            restPeopleNum--;
            amountList.add(amount);
        }
        amountList.add(restAmount);
        return amountList;
    }

    public static void main(String[] args) {

        List<Integer> amountList = divideRedPackage(5000, 30);

        for (Integer amount : amountList) {
            System.out.println("抢到金额：" + new BigDecimal(amount).divide(new BigDecimal(100)));
        }
        
    }
}